<template>
  <div class="record">
    <div class="card">
      <h1>上映时间轴</h1>
      <div class="timelineBox">
        <el-timeline>
          <el-timeline-item
            v-for="(fid, index) in tableData"
            v-show="fid.filmDate > time"
            :key="index"
            :size="large"
            :timestamp="fid.filmDate"
            :color="point_color"
            placement="top"
          >
            <div v-show="index % 2 == 0" class="evenDiv">
              <div class="timelinItemBox0">
                <div
                  class="timelinItemBox-bottom"
                  style="background-color: #5cacee"
                >
                  <img
                    :src="fid.picture"
                    class="rdpic"
                    @click="filmdetail(filmid.link)"
                  />
                  <div class="rdright">
                    <h2 class="rdname" @click="filmdetail(fid.link)">
                      {{ fid.name }}
                    </h2>
                    <h2 class="rdtype">类型：{{ fid.type }}</h2>
                    <h2 class="rdauthor">导演：{{ fid.director }}</h2>
                    <h2 class="rdactor">主演：{{ fid.star }}</h2>
                  </div>
                </div>
              </div>
              <div class="timelinItemBox1">
                <div class="timelinItemBox-top f-r a-c"></div>
                <div class="timelinItemBox-bottom"></div>
              </div>
            </div>

            <div v-show="index % 2 == 1" class="unevenDiv">
              <div class="timelinItemBox0">
                <div class="timelinItemBox-top f-r a-c"></div>
                <div class="timelinItemBox-bottom"></div>
              </div>
              <div class="timelinItemBox1">
                <!-- <div
                class="timelinItemBox-top f-r a-c"
                style="background-color: #ccffff"
              >
              </div> -->
                <div
                  class="timelinItemBox-bottom"
                  style="background-color: #5cacee"
                >
                  <img
                    :src="fid.picture"
                    class="rdpic1"
                    @click="filmdetail(filmid.link)"
                  />
                  <div class="rdright">
                    <h2 class="rdname1" @click="filmdetail(fid.link)">
                      {{ fid.name }}
                    </h2>
                    <h2 class="rdtype">类型：{{ fid.type }}</h2>
                    <h2 class="rdauthor">导演：{{ fid.director }}</h2>
                    <h2 class="rdactor">主演：{{ fid.star }}</h2>
                  </div>
                </div>
              </div>
            </div>
          </el-timeline-item>
        </el-timeline>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      point_color: "#D1D1D1",
      tableData: [],
    };
  },
  methods: {
    filmdetail(e) {
      // window.location.href = e,'_blank'
      window.open(e, "_blank");
    },
  },
  mounted() {
    //年
    let year = new Date().getFullYear();
    //月份是从0月开始获取的，所以要+1;
    let month = new Date().getMonth() + 1;
    //日
    let day = new Date().getDate();
    if (month >= 1 && month <= 9) {
      month = "0" + month;
    }
    if (day >= 0 && day <= 9) {
      day = "0" + day;
    }
    let time = year + "-" + month + "-" + day;
    this.time = time;
    var _this = this;
    this.$http.get("/film/v1/readyFilm").then(function (response) {
      console.log(response.data);
      _this.tableData = response.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.rdtime {
  text-align: center;
  margin: auto;
  position: absolute;
  left: 0;
  right: 0;
}
.rdright {
  width: 420px;
}
.rdname {
  margin-top: -179px;
  font-size: 24px;
  margin-left: 150px;
  color: rgb(255, 255, 255);
}
.rdname1 {
  margin-top: -170px;
  font-size: 24px;
  margin-left: 150px;
  width: 450px;
  color: rgb(255, 255, 255);
}
.rdtype {
  margin-left: 150px;
  font-size: 14px;
  font-weight: 200;
  margin-top: -10px;
}
.rdauthor {
  margin-left: 150px;
  font-size: 14px;
  font-weight: 200;
  margin-top: -10px;
}
.rdactor {
  margin-left: 150px;
  font-size: 14px;
  font-weight: 200;
  margin-top: -10px;
  height: 77px;
  overflow-y: hidden;
}
.h-100 {
  height: 100%;
}
.p-r {
  position: relative;
}
.f-r {
  display: flex;
  flex-direction: row;
}
.a-c {
  align-content: center;
  align-items: center;
}
.m-l20 {
  margin-left: 20px;
}

.timelineBox {
  width: 520px;
  margin-top: 20px;
  margin-left: 600px;
  .el-timeline-item {
    padding-bottom: 30px;
  }
}
.timelinItemBox0 {
  width: calc(100% - 28px - 2px);
  height: calc(100% - 2px);
  position: absolute;
  right: calc(100% + 18px);
  // border: 2px solid #dedede;
  border-radius: 5px;
}
.timelinItemBox1 {
  width: calc(100% - 28px - 2px);
  height: calc(100% - 2px);
  // border: 2px solid #dedede;
  border-radius: 5px;
}
.timelinItemBox-top {
  height: 35px;
  padding: 0 10px;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  color: #ffffff;
}
.timelinItemBox-bottom {
  padding: 10px;
  width: 440px;
  height: 220px;
  color: #eeeeee;
  line-height: 20px;
  white-space: pre-wrap;
  border-radius: 10px;
}
.rdpic {
  width: 130px;
  height: 184px;
  margin-top: 8px;
  margin-left: 5px;
}
.rdpic1 {
  width: 130px;
  height: 186px;
  margin-top: 8px;
  margin-left: 5px;
}
.evenDiv {
  .timelinItemBox1 {
    // border: 1px solid #ffffff;
    -moz-user-select: none;
    -khtml-user-select: none;
    user-select: none;
    .timelinItemBox-bottom {
      color: #ffffff;
    }
  }
}
.unevenDiv {
  .timelinItemBox0 {
    // border: 1px solid #ffffff;
    -moz-user-select: none;
    -khtml-user-select: none;
    user-select: none;
    .timelinItemBox-bottom {
      color: #ffffff;
    }
  }
}
.card {
  width: 1280px;
  margin-left: -20px;
  background-color: #ffffff;
  border: 2px solid #cee6f8;
  border-radius: 10px;
}
.record {
  background-color: #ebecec;
  color: #5b5bf0;
  font-family: Lato, sans-serif;
  padding: 20px 40px;
  width: 100%;
  overflow-y: auto;
  overflow: moz;
  h1 {
    font-size: 2.5em;
    text-transform: uppercase;
    letter-spacing: 10px;
    text-align: center;
    font-family: Lora, serif;
    font-weight: 200;

    &::before {
      content: "─";
      margin-right: 0.6em;
      color: #686868;
      color: #d8d8d8;
    }
    &::after {
      content: "─";
      margin-left: 0.6em;
      color: #686868;
      color: #d8d8d8;
    }
  }
}
</style>
